package com.day0906;

import java.util.Scanner;

public class Text7_task {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String answer;
        do{
            System.out.println("简易计算器");
            System.out.print("请输入第一个数：");
            int num1 = in.nextInt();
            System.out.print("请输入第二个数：");
            int num2  = in.nextInt();
            System.out.print("请输入运算符：");
            String charater = in.next();
            double sum;
            if(charater.equals("+")){
                sum = num1 + num2;
                System.out.println(num1 + "+" + num2 + "=" + sum);
            }
            else if(charater.equals("-")){
                sum = num1 - num2;
                System.out.println(num1 + "-" + num2 + "=" + sum);
            }
            else if(charater.equals("*")){
                sum = num1 * num2;
                System.out.println(num1 + "*" + num2 + "=" + sum);
            }
            else if(charater.equals("/")){
                if(num2 != 0){
                    sum = num1 / num2;
                    System.out.println(num1 + "/" + num2 + "=" + sum);
                }
                else {
                    System.out.println("除数不能为0，请重新输入：");
                    num2 = in.nextInt();
                    sum = num1 / num2;
                    System.out.println(num1 + "/" + num2 + "=" + sum);
                }
            }
            System.out.print("继续吗？（y/n）：");
            answer = in.next();
        }while (answer.equals("y"));
        System.out.println("谢谢使用！");

    }
}
